package www.sofn.com.goods.domain.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import www.sofn.com.validate.group.UpdateGroup;

import java.math.BigDecimal;
import java.util.List;

@Data
@ToString
@Accessors(chain = true)
@Schema(description = "商品信息")
public class GoodsVO {
    @Schema(description = "商品Id")
    @NotBlank(message = "商品Id不能为空",groups = {UpdateGroup.class})
    private String id;
    @Schema(description = "商品名称")
    @Length(max = 60 ,min = 2,message = "商品名称{min}~{max}个字符")
    private String goodsName; //商品名称
    @Schema(description = "商品轮播")
    @NotBlank(message = "商品轮播最少3个素材")
    private String goodsCarousel; //商品轮播
    @NotNull(message = "商品属性不能为空")
    @Schema(description = "商品属性")
    private GoodsAttr goodsAttr; //商品属性
    @NotBlank(message = "商品详情图片最少3个素材")
    @Schema(description = "商品详情图片")
    private String goodsInfoImg;
    @Schema(description = "商品规格参数")
    private List<GoodsSpecs> goodsSpecs;
    @Data
    @Accessors(chain = true)
    @ToString
    public static class GoodsSpecs {  //商品规格
        @Schema(description = "商品规格K")
        private String k;
        @Schema(description = "商品规格V")
        private String v;
    }

    @Data
    @Accessors(chain = true)
    @ToString
    public static class GoodsAttr {//商品sku属性
        private String attrName; //属性名称
        private  List<AttrInfo> attrValue;
    }

    @Data
    @Accessors(chain = true)
    @ToString
    public static class AttrInfo {
        @Schema(description = "属性值")
        private String value; // 属性值
        @Schema(description = "属性图片")
        private String img; //属性图片
        @Digits(integer = 4, fraction = 2,message = "会员价格的精度为2位,最大值为:10000")
        @Schema(description = "会员价格")
        private BigDecimal memberPrice; //会员价格
        @Digits(integer = 4, fraction = 2,message = "市场价格的精度为2位,最大值为:10000")
        @Schema(description = "市场价格")
        private BigDecimal marketPrice;//市场价格
        @Max(value = 10000,message = "库存不能大于{value}")
        @Schema(description = "库存")
        private Integer inventory;  //库存
    }

}
